﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HeapModel;
using HeapModel.ProgInfo;
using HeapModel.RegionPartition;

namespace MetricExtractor
{
	internal sealed class MetricInfo
	{
		private readonly string m_pname;
		private readonly IndivRegionMetrics m_indivrgn;
		private readonly IndivEdgeMetrics m_indivedge;
		private readonly BasicHeapStructureMetrics m_structureinfo;

		internal MetricInfo(string progname, Dictionary<string, Tuple<bool, int>> singleregiontype)
		{
			this.m_pname = progname;
			this.m_indivrgn = new IndivRegionMetrics(singleregiontype);
			this.m_indivedge = new IndivEdgeMetrics();
			this.m_structureinfo = new BasicHeapStructureMetrics();
		}

		internal void Extract(RegionGraph hg, Dictionary<string, Tuple<bool, int>> singleregioninfoandcountmap)
		{
			this.m_indivrgn.Extract(hg);
			this.m_indivedge.Extract(hg, singleregioninfoandcountmap);
			this.m_structureinfo.Extract(hg, singleregioninfoandcountmap);
		}

		internal string CSVFormatRgn()
		{ return m_pname + ", " + this.m_indivrgn.CSVFormatRgn(); }

		internal string CSVFormatRgnInEdge()
		{ return m_pname + ", " + this.m_indivrgn.CSVFormatRgnInEdges(); }

		internal string CSVFormatEdges()
		{ return m_pname + ", " + this.m_indivedge.CSVFormat(); }

		internal string CSVFormatStructure()
		{ return m_pname + ", " + this.m_structureinfo.CSVFormat(); }
	}
}
